﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    /// <summary>
    /// 信息文档接收对象 逻辑类
    /// </summary>
    public class DocRecObject
    {
        /// <summary>
        /// 信息文档接收对象 数据类
        /// </summary>
        private DAL.DocRecObject docRecObjectDAL = new DAL.DocRecObject();
        /// <summary>
        /// 构造函数
        /// </summary>
        public DocRecObject()
        {
        }
        /// <summary>
        /// 从视图中根据公司编号和信息编号获得数据列表
        /// <creator>wangl</creator>
        /// <date>2013-08-16</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="docId">信息编号</param>
        /// <returns></returns>
        public List<Model.DocRecObject> GetListByView(string entityNo, decimal docId)
        {
            DataSet ds = docRecObjectDAL.GetListByView(entityNo,docId);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// <creator>wangl</creator>
        /// <date>2013-08-16</date>
        /// </summary>
        private List<ElingOA6_Admin_DSJCJ.Model.DocRecObject> DataTableToList(DataTable dt)
        {
            List<ElingOA6_Admin_DSJCJ.Model.DocRecObject> modelList = new List<ElingOA6_Admin_DSJCJ.Model.DocRecObject>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_Admin_DSJCJ.Model.DocRecObject model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = docRecObjectDAL.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
    }
}
